package com.cate.controller.user;

import com.cate.constants.StatusConstant;
import com.cate.pojo.entity.Setmeal;
import com.cate.pojo.vo.DishItemVO;
import com.cate.pojo.vo.SetmealVO;
import com.cate.result.RestResponse;
import com.cate.service.SetmealService;
import com.cate.utils.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @CreateTime: 2023/8/1
 * @Author: <==lhd==>
 * @Description:
 */

@RestController("UserSetmealController")
@Slf4j
@RequestMapping("/user/setmeal")
@Api(tags = "用户端套餐接口")
public class SetmealController {

    @Autowired
    private SetmealService setmealService;

    @GetMapping("/dish/{id}")
    @ApiOperation("根据套餐id查询包含的菜品")
    public RestResponse<List<DishItemVO>>  getDishListById(@PathVariable("id") Long id){
        final List<DishItemVO> list = setmealService.getDishItemById(id);
        return ResultUtil.success(list);
    }


    @GetMapping("/list")
    @ApiOperation("根据分类id查询套餐")
    public RestResponse<List<Setmeal>> getSetmealListByCategoryId(Long categoryId){
        Setmeal setmeal = new Setmeal();
        setmeal.setCategoryId(categoryId);
        setmeal.setStatus(StatusConstant.ENABLE);

        List<Setmeal> list = setmealService.list(setmeal);
        return ResultUtil.success(list);
    }
}
